Passed
Push — master ( 6b32d9...9f4747 )
by MusikAnimal
02:02
created

articleinfo.js ➔ ... ➔ setupToggleTable   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
dl 0
loc 8
rs 9.4285
nop 0
1
$(function () {
2
    if (!$('body.articleinfo').length) {
3
        return;
4
    }
5
6
    var setupToggleTable = function () {
7
        window.setupToggleTable(
8
            window.textshares,
9
            window.textsharesChart,
10
            'percentage',
11
            $.noop
12
        );
13
    };
14
15
    var $textsharesContainer = $('.textshares-container');
16
17
    if ($textsharesContainer[0]) {
18
        /** global: xtBaseUrl */
19
        var url = xtBaseUrl + 'articleinfo-authorship/'
20
            + $textsharesContainer.data('project') + '/'
21
            + $textsharesContainer.data('article') + '?htmlonly=yes';
22
23
        $.ajax({
24
            url: url,
25
            timeout: 30000
26
        }).done(function (data) {
27
            $textsharesContainer.replaceWith(data);
28
            setupTocListeners();
29
            setupColumnSorting();
30
            setupToggleTable();
31
        }).fail(function (_xhr, _status, message) {
32
            $textsharesContainer.replaceWith(
33
                $.i18n('api-error', 'Authorship API: <code>' + message + '</code>')
34
            );
35
        });
36
    } else if ($('.textshares-table').length) {
37
        setupToggleTable();
38
    }
39
});
40